<?php
namespace app\mini\controller;
class Pre extends \think\Controller
{
    //前初始化
    protected function initialize(){
        //验证登陆
        $data = input('param.');
        $url = $_SERVER['REMOTE_ADDR'];
        if ($url =='127.0.0.1')
            $data['token'] = 'd9e15d651a22c946bfc32546678e44bd5d0e8d09';

        $cacheInfo = cache($data['token']);

        $userInfo = \app\common\model\Account::where('telephone',$cacheInfo['telephone'])->find();
        //验证成功
        if ($cacheInfo['auth'] =='admin' && $userInfo){
            //区分渠道公司和代理公司
            $channel = [
                '驻场总监' => '22',
                '驻场经理' => '26',
                '客服总监' => '23',
                '客服经理' => '27',
            ];
            $this -> channel = in_array($userInfo['role'],$channel)?true:false;

            $this -> loginInfo = $userInfo;
            $this -> data = $data;
            return true;
        }


        json([
            'code' => '400',
            'message' => '登陆已过期，请重新登陆'
        ])
            ->send();
        exit;

    }
}